
 //@version=6
indicator("Manual Trading Checklist | OB & Momentum", shorttitle="Trade Checklist", overlay=true)

// =============================================
// 01 - QUICK CHECKLIST
// =============================================
// Check all conditions here.
// Zone Rule is directly after 1H Momentum.

g1 = "01 - QUICK CHECKLIST"

c1 = input.bool(false, "1H Momentum + OB Return", group=g1)
c2 = input.bool(false, "Zone Rule", group=g1)
c3 = input.bool(false, "15M Momentum Break", group=g1)
c4 = input.bool(false, "5M Momentum Break", group=g1)
c5 = input.bool(false, "3M/1M Common Sense", group=g1)
c6 = input.bool(false, "Targets: LIQ / OB", group=g1)
c7 = input.bool(false, "Risk Management", group=g1)
c8 = input.bool(false, "Daily Goal", group=g1)
c9 = input.bool(false, "Timing", group=g1)

// =============================================
// 02 - TRADE SETTINGS
// =============================================

g2 = "02 - TRADE SETTINGS"

direction = input.string("BUY", "Trade Direction",
     options=["BUY", "SELL"], group=g2)

targetType = input.string("Liquidity (Impulsive)", "Target",
     options=["Liquidity (Impulsive)", "OB (Pullback)"],
     group=g2)

// =============================================
// 03 - CUSTOM RULE NAMES
// =============================================

g3 = "03 - CUSTOM RULE NAMES"

n1 = input.string("1H Momentum + 1H/45M OB Return", "Rule 1", group=g3)
n2 = input.string("Zone Break OR 15M/5M Reversal", "Rule 2", group=g3)
n3 = input.string("15M Momentum Break", "Rule 3", group=g3)
n4 = input.string("5M Momentum Break", "Rule 4", group=g3)
n5 = input.string("3M/1M Common Sense", "Rule 5", group=g3)
n6 = input.string("Target Confirmed", "Rule 6", group=g3)
n7 = input.string("Risk Management", "Rule 7", group=g3)
n8 = input.string("Daily Goal", "Rule 8", group=g3)
n9 = input.string("Timing", "Rule 9", group=g3)

// =============================================
// 04 - DASHBOARD SETTINGS
// =============================================

g4 = "04 - DASHBOARD SETTINGS"

dashboardTitle = input.string("TRADING CHECKLIST", "Title", group=g4)

dashboardPosition = input.string("Top Right", "Position",
     options=[
         "Top Left",
         "Top Center",
         "Top Right",
         "Middle Left",
         "Middle Center",
         "Middle Right",
         "Bottom Left",
         "Bottom Center",
         "Bottom Right"
     ], group=g4)

fontChoice = input.string("Small", "Text Size",
     options=["Tiny", "Small", "Normal", "Large"],
     group=g4)

showNumbers = input.bool(true, "Show Rule Numbers", group=g4)
showTarget = input.bool(true, "Show Target", group=g4)
showProgress = input.bool(true, "Show Progress", group=g4)
showPercentage = input.bool(true, "Show Percentage", group=g4)
showStatus = input.bool(true, "Show Final Status", group=g4)

// =============================================
// 05 - COLORS
// =============================================

g5 = "05 - CUSTOM COLORS"

headerBg = input.color(color.rgb(15, 23, 42), "Header Background", group=g5)
rowBg = input.color(color.rgb(30, 41, 59), "Row Background", group=g5)
textColor = input.color(color.white, "Text Color", group=g5)
passColor = input.color(color.rgb(34, 197, 94), "Completed Color", group=g5)
waitColor = input.color(color.rgb(156, 163, 175), "Pending Color", group=g5)
accentColor = input.color(color.rgb(250, 204, 21), "Accent Color", group=g5)
sellColor = input.color(color.rgb(239, 68, 68), "SELL Color", group=g5)
borderColor = input.color(color.rgb(71, 85, 105), "Border Color", group=g5)

// =============================================
// 06 - POSITION AND FONT
// =============================================

panelPos = switch dashboardPosition
    "Top Left" => position.top_left
    "Top Center" => position.top_center
    "Middle Left" => position.middle_left
    "Middle Center" => position.middle_center
    "Middle Right" => position.middle_right
    "Bottom Left" => position.bottom_left
    "Bottom Center" => position.bottom_center
    "Bottom Right" => position.bottom_right
    => position.top_right

fontSize = switch fontChoice
    "Tiny" => size.tiny
    "Normal" => size.normal
    "Large" => size.large
    => size.small

// =============================================
// 07 - CHECKLIST DATA
// =============================================

checks = array.from(c1, c2, c3, c4, c5, c6, c7, c8, c9)

names = array.from(n1, n2, n3, n4, n5, n6, n7, n8, n9)

int completed = 0
int total = 9

for i = 0 to 8
    if array.get(checks, i)
        completed += 1

float percent = completed * 100.0 / total
bool ready = completed == total

// =============================================
// 08 - DASHBOARD TABLE
// =============================================

var table panel = table.new(
     panelPos,
     2,
     14,
     bgcolor=rowBg,
     border_width=1,
     border_color=borderColor,
     frame_width=1,
     frame_color=borderColor)

// =============================================
// 09 - RENDER CHECKLIST
// =============================================

if barstate.islast

    table.clear(panel, 0, 0, 1, 13)

    // HEADER
    table.cell(
         panel, 0, 0, dashboardTitle,
         text_color=textColor,
         bgcolor=headerBg,
         text_size=fontSize,
         text_halign=text.align_left)

    table.cell(
         panel, 1, 0, direction,
         text_color=direction == "BUY" ? passColor : sellColor,
         bgcolor=headerBg,
         text_size=fontSize)

    int row = 1

    // TARGET SECTION
    if showTarget
        table.cell(
             panel, 0, row, "TARGET TYPE",
             text_color=textColor,
             bgcolor=headerBg,
             text_size=fontSize)

        table.cell(
             panel, 1, row, targetType,
             text_color=accentColor,
             bgcolor=headerBg,
             text_size=fontSize)

        row += 1

    // CHECKLIST ITEMS
    for i = 0 to 8

        bool checked = array.get(checks, i)
        string ruleName = array.get(names, i)

        string displayName = showNumbers ?
             str.tostring(i + 1) + ". " + ruleName :
             ruleName

        string statusText = checked ? "✓ DONE" : "○ WAIT"

        color statusColor = checked ? passColor : waitColor

        table.cell(
             panel, 0, row, displayName,
             text_color=textColor,
             bgcolor=rowBg,
             text_size=fontSize,
             text_halign=text.align_left)

        table.cell(
             panel, 1, row, statusText,
             text_color=statusColor,
             bgcolor=rowBg,
             text_size=fontSize,
             text_halign=text.align_center)

        row += 1

    // PROGRESS SECTION
    if showProgress

        string progressText = str.tostring(completed) + "/" + str.tostring(total)

        if showPercentage
            progressText += " (" + str.tostring(percent, "#.0") + "%)"

        table.cell(
             panel, 0, row, "CHECKLIST PROGRESS",
             text_color=textColor,
             bgcolor=headerBg,
             text_size=fontSize)

        table.cell(
             panel, 1, row, progressText,
             text_color=ready ? passColor : accentColor,
             bgcolor=headerBg,
             text_size=fontSize)

        row += 1

    // FINAL STATUS
    if showStatus

        string finalText = ready ?
             "ALL CONDITIONS CHECKED" :
             "WAIT FOR CONFIRMATION"

        string finalState = ready ? "READY" : "WAIT"

        table.cell(
             panel, 0, row, finalText,
             text_color=ready ? passColor : accentColor,
             bgcolor=headerBg,
             text_size=fontSize)

        table.cell(
             panel, 1, row, finalState,
             text_color=ready ? passColor : waitColor,
             bgcolor=headerBg,
             text_size=fontSize)
